package Controller.StudentServlet;

import Dao.StudentDao;
import bean.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/student_search")
public class student_search extends HttpServlet {
    StudentDao studentDao = new StudentDao();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String sname = req.getParameter("sname");

        ArrayList<Student> list = studentDao.selectBySname(sname);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
//        req.setAttribute("student_list", list);
//        req.getRequestDispatcher("StudentInfoSelect.jsp").include(req, resp);
    }
}
